<?php

namespace App\Http\Requests;

class RegisterRequest extends BaseRequest {
    /**
     * Get the validation rules that apply to the request.
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'username' => 'required|min:5|max:100|unique:users',
            'password' => 'required|string',
            'mobile' => 'required|regex:/^1[0-9]{10}$/',
            'code' => 'required',
        ];
    }

    public function messages(): array
    {
        return [
            'username.required' => '用户名不能为空。',
            'username.unique' => '用户名已存在',
            'mobile.regex' => '手机号格式不正确'
        ];
    }
}
